# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=tcpdump
pkgver=4.99.1
pkgrel=1
pkgdesc='Powerful command-line packet analyzer'
url="https://www.tcpdump.org/"
arch=('x86_64')
license=('BSD')
depends=('glibc' 'openssl')
makedepends=('cmake' 'libpcap' 'libcap-ng')
source=("https://www.tcpdump.org/release/${pkgname}-${pkgver}.tar.gz"{,.sig})
sha512sums=('53d31355e1a6ef5a65bb3bf72454169fc80adf973a327a5768840e6ccf0550fbeb3c8a41f959635076d871df0619680321910a3a97879607f481cdaa8b7ceda7'
            'SKIP')
b2sums=('0a10fe68afdfe80d3e7e661352fcaf1c47702df27fbed959f52fb0ec81543a1d4ce6b0de16a8b081de48dd43e09a13f5e1f0fb11d7590f92cbff29dc511bea12'
        'SKIP')
validpgpkeys=('1F166A5742ABB9E0249A8D30E089DEF1D9C15D0D') # The Tcpdump Group (Package signing key) <release@tcpdump.org>

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE='None' \
        -Wno-dev \
        -B build \
        -S .
  make VERBOSE=1 -C build
}

check() {
  cd "${pkgname}-${pkgver}"
  make VERBOSE=1 check -C build
}

package() {
  depends+=('libpcap.so' 'libcap-ng.so')
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install -C build
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
